
#include "gps_proto_util.h"

#include "gps.pb.h"
#include "gtest/gtest.h"

namespace gps_proto {

TEST(GpsProtoUtilTest, TotalSegmentDistanceOnTwoPoints) {
  SegmentProto segment;
  PointProto* point = segment.add_point();
  point->set_lon(-122.441854561);
  point->set_lat(37.802731572);
  point->set_ele(4.943848);
  point = segment.add_point();
  point->set_lon(-122.441867888);
  point->set_lat(37.802738529);
  point->set_ele(3.982666);
  ASSERT_DOUBLE_EQ(1.7001817156960788, TotalSegmentDistance(segment, NULL, NULL));
  double ascent = 0;
  double descent = 0;
  ASSERT_DOUBLE_EQ(1.7001817156960788, TotalSegmentDistance(segment, &ascent,
                                                            &descent));
  ASSERT_EQ(0, ascent);
  ASSERT_EQ(-0.961182, descent);
}

}

int main(int argc, char** argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

